var http = require('http');
/*
 * GET home page.
 */

module.exports = function(app){

    /* RESTful API */
//    app.all(/^\/(node(domain)?|softwares|datasource|modules|objs|roles|users|organizations|workbench|funcs|models|alert|analytics|audits|features|logout|report|dashboardmeta).*/, function(requ, response) {
    app.all(/^\/NewsService\/.*/, function(requ, response) {

        var options = {
//            host: '218.240.156.199',
            host:'',
            port: 80,
            path: requ.url,
            method: requ.method,
            headers: {
                "Accept": "*/*",
                'Content-Type': 'application/json;charset=utf-8'
            }
        }
        var req = http.request(options, function(res) {
            var statusCode = res.statusCode,
                data = '';
            res.on('data', function(chunk) {
                data += chunk;
            });
            res.on('end', function() {
                response.send(statusCode, data);
            })
        });
        req.write(JSON.stringify(requ.body));
        req.end();
        req.on('error', function(e) {
            console.log(e);
            response.send('');
        })
    });



}
